package com.cuitrip.business.tripservice.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.lab.adapter.IAdapterData;

import java.io.Serializable;

/**
 * Created by sheena on 16/1/7.
 */
public class CategoryInfo implements Parcelable, Serializable, IAdapterData {
    public static final Creator<CategoryInfo> CREATOR = new Creator<CategoryInfo>() {
        @Override
        public CategoryInfo createFromParcel(Parcel in) {
            return new CategoryInfo(in);
        }

        @Override
        public CategoryInfo[] newArray(int size) {
            return new CategoryInfo[size];
        }
    };
    /**
     * "result": [
     {
     "category": "1000000",
     "name": "Lifestyle",
     "parent": "0"
     },
     {
     "category": "2000000",
     "name": "Food & Cuisine",
     "parent": "0"
     },
     {
     "category": "3000000",
     "name": "Adventure & Sports",
     "parent": "0"
     },
     {
     "category": "4000000",
     "name": "Culture & Sights",
     "parent": "0"
     }
     ]
     */
    private String category;
    private String name;
    private String parent;
    private boolean isSelected;

    public CategoryInfo() {
    }


    protected CategoryInfo(Parcel in) {
        category = in.readString();
        name = in.readString();
        parent = in.readString();
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getParent() {
        return parent;
    }

    public void setParent(String parent) {
        this.parent = parent;
    }

    @Override
    public boolean equals(Object o) {
        if (o == null) {
            return false;
        }
        if (this == o)
        {
            return true;
        }
        if (o instanceof CategoryInfo) {
            CategoryInfo n = (CategoryInfo)o;
            return this.category.equals(n.category);
        }
        return false;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(category);
        dest.writeString(name);
        dest.writeString(parent);
    }

    public boolean isSelected() {
        return isSelected;
    }

    public void setSelected(boolean selected) {
        isSelected = selected;
    }
}
